{extend name="public/base" /}

{block name="title"}<title>{if condition="$data"}{$Think.lang.edit}{else /}{$Think.lang.create}{/if}</title>{/block}

{block name="pjax_container"}
<div class="hry-content-wrapper">
<section class="content-header">
    <ol class="breadcrumb">
		<li>企业端管理</li>
		<li class="active">项目方列表</li>
		<li class="active">新增项目方</li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <form class="form-horizontal" id="project" name="forms" method="POST" action="" onsubmit="return false" >
                <div class="nav-tabs-custom">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_base" data-toggle="tab">项目方信息</a></li>
                        <li class="pull-right"><a href="javascript:history.back(-1)" class="btn btn-sm" style="padding:10px 2px;"><i class="fa fa-list"></i> {$Think.lang.back}</a></li>
                    </ul>
                    <div class="tab-content">
						<div class="tab-pane active" id="tab_base">
                            <div class="form-group">
                                <label class="col-sm-2 control-label hry-require">（W:80 H:80）logo</label>
                                <div class="col-sm-7 input-group" style="padding-left: 15px">
                                    <input class="form-control" name="logo" value="" style="width: 80%;display: inline-block" placeholder="图片地址" >
                                    <span class="input-group-btn" style="display: inline-block">
                                             <img src="/static/global/face/no-image.png" style="height:34px; width:68px;" />
                                            <button class="btn btn-success btn-flat upload-button" type="button" data-url="{:url('ProjectSide/companyUpload')}">
                                                <i class="fa fa-cloud-upload"> {$Think.lang.Upload}</i>
                                            </button>
                                     </span>
                                </div>
                            </div>
							<div class="form-group">
								<label class="col-sm-2 control-label hry-require">项目方名称</label>
								<div class="col-sm-7"><input required class="form-control" name="company_name" id="company_name" value="" placeholder="项目方名称"></div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label hry-require">项目方介绍</label>
								<div class="col-sm-7"><textarea required class="form-control type=textarea" name="company_intro" id="company_intro"  placeholder="项目方介绍"></textarea></div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label hry-require">法人手机号</label>
								<div class="col-sm-7"><input required class="form-control" name="mobile" id="mobile" value="" placeholder="法人手机号"></div>
							</div>
						</div>
                    </div>
                    <div class="box-footer">
                        <div class="col-sm-2"></div>
                        <div class="col-sm-7">
                            <div class="btn-group pull-right">
                                <button type="submit" id="hrySubmit" class="btn btn-info pull-right" data-loading-text="&lt;i class='fa fa-spinner fa-spin '&gt;&lt;/i&gt; {$Think.lang.submit}">{$Think.lang.submit}</button>
                            </div>
                            <div class="btn-group pull-left">
                                <button type="reset" class="btn btn-warning">{$Think.lang.reset}</button>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</section>
</div>
<script type="text/javascript" src="__STATIC__/hry/js/spark-md5.js"></script>
<script type="text/javascript">

$(function(){
    $("#project").submit(function () {
        if(validateForm()){
            var d = {};
            var t = $("#project").serializeArray(); // 默认是json 格式
            //jQuery的循环
            $.each(t, function() {
                d[this.name] = this.value;
                console.info(d)
            });
            var json_str = JSON.stringify(t);
            submitForm(d)
        }
    })
    {if condition=" $rest_login == 1 "}
    restlogin('{$rest_login_info}');   //登录超时
    {/if}
})
    function submitForm(filed) {
            $.ajax({
                url: 'createprojectmanager',
                data: filed,
                type: "POST",
                dataType: "json",
                success: function (result) {
                    if (result.status == 1) {
                        $.amaran({'message': result.info});
                        window.location.href = result.url;
                    } else {
                        $.amaran({'message': result.info});
                    }
                },
                error: function (result, xhr, status, errorThrown) {
                    $.amaran({'message': result.info})
                },
                complete: function (xhr, status) {
//                    alert('The request is complated');
                },
                beforesend: function () {
                },
                cache: false,//true
                async: true
            })
    }
    function validateForm() {
        let id = $('#mobile').val()
        var idreg = /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/;
        let validate = false
        if (!idreg.test(id)) {
            $.amaran({'message': '请输入正确的手机!'});
            validate = false
        } else {
            validate = true
        }
        return validate
    }
</script>
{/block}